package com.lqian.service.note;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lqian.mapper.NoteMapper;
import com.lqian.pojo.Note;
import com.lqian.utils.PageUtil;

@Service
public class NoteServiceImpl implements NoteService{

	
	@Autowired 
	private NoteMapper noteMapper;

	/**
	 * 分页查询所有请假列表
	 * 分页查询  返回值 是集合  参数：pageUtil对象
	 */

	@Override
	public List<Note> findAllNote(PageUtil page) {
		return noteMapper.findAllNote(page);
	}

	
	/**
	 * 查询所以的记录行条数
	 */
	@Override
	public Integer count() {
		return noteMapper.count();
	}
	/*//审核状态，0：待审核；1：同意；2：打回；3：不同意
	@Insert("insert note(nid,title,context,startdate,enddate,LENGTH,SUBDATE,estatus,eid)"
			+ " values(NULL,#{title},#{title},#{startdate},#{enddate},#{LENGTH},#{SUBDATE},#{estatus},#{eid})")*/
	@Override
	public Integer applyNote(Note note) {
		
		//设置审批时间默认为当前
		note.setSubdate(new Date());
		//默认待审批
		note.setEstatus(0);
		return noteMapper.applyNote(note);
	}


	@Override
	public Integer agree(Integer nid) {
		return noteMapper.agree(nid);
	}


	@Override
	public Integer reback(Integer nid) {
		return noteMapper.reback(nid);
	}


	@Override
	public Integer disagree(Integer nid) {
		return noteMapper.disagree(nid);
	}
	
	
	}
